<template>
  <div class="video_discuss">
    <div class="video_discuss_total">0 条评论</div>
    <div class="comment-component-tabs__container">
      <div class="comment-component-tab">
        <button
          class="comment-component-tabs__tabItem"
          :class="{ active: isHot }"
          tabindex="0"
          role="switch"
          aria-checked="true"
          @click="changeOrder(true)"
        >
          热度排序
        </button>
        <div class="comment-component-tabs__ink"></div>
      </div>
      <div class="comment-component-tab">
        <button
          class="comment-component-tabs__tabItem"
          :class="{ active: !isHot }"
          tabindex="0"
          role="switch"
          aria-checked="false"
          @click="changeOrder(false)"
        >
          时间排序
        </button>
        <div class="comment-component-tabs__ink"></div>
      </div>
    </div>
    <div class="commentWriter">
      <div class="commentWriter_avatar">
        <el-avatar :icon="User" />
      </div>
      <div class="commentWriter_container">
        <input
          class="commentWriter_container_input"
          placeholder="善语如三月春风，恶语似腊月寒冬"
          v-model="commentContent"
          @keyup.enter="sendComment"
        />
        <V3Emoji class="commentWriter_emoji" @click-emoji="clickEmoji" />
        <button class="commentWriter_container_btn" @click="sendComment">发送</button>
      </div>
    </div>
    <div class="comment_list" v-for="item in mockData" :key="item.id">
      <CommentItem :comment="item" />
    </div>
  </div>
</template>
<script setup lang="ts">
  import { ref } from 'vue';
  import V3Emoji from 'vue3-emoji';
  import 'vue3-emoji/dist/style.css';
  import CommentItem from './CommentItem.vue';
  import { User } from '@element-plus/icons-vue';

  const isHot = ref(true);
  const leftPx = ref(22);
  const commentContent = ref('');

  const changeOrder = (state: boolean) => {
    isHot.value = state;
    leftPx.value = state ? 22 : 94;
  };

  const clickEmoji = (val: any) => {
    commentContent.value += val;
  };

  const sendComment = () => {};

  const mockData = [
    {
      id: 12312213,
      username: '什锦1',
      avatar:
        '//sf1-cdn-tos.bdxiguastatic.com/img/user-avatar/e2580b2bb3d06dc4b805488ea57a8e0a~80x80.image',
      createTime: '2020-7-12',
      commentContent: '作者我给你99怕你多了一分，你我怕你骄傲。',
      thumbsUpCount: 5,
      replayCount: 2,
      isAgree: false,
    },
    {
      id: 12312213,
      username: '什锦2',
      avatar:
        '//sf1-cdn-tos.bdxiguastatic.com/img/user-avatar/e2580b2bb3d06dc4b805488ea57a8e0a~80x80.image',
      createTime: '2020-7-12',
      commentContent: '作者我给你99怕你多了一分，你我怕你骄傲。',
      thumbsUpCount: 5,
      replayCount: 2,
      isAgree: false,
    },
    {
      id: 12312213,
      username: '什锦3',
      avatar:
        '//sf1-cdn-tos.bdxiguastatic.com/img/user-avatar/e2580b2bb3d06dc4b805488ea57a8e0a~80x80.image',
      createTime: '2020-7-12',
      commentContent: '作者我给你99怕你多了一分，你我怕你骄傲。',
      thumbsUpCount: 5,
      replayCount: 2,
      isAgree: false,
    },
    {
      id: 123122134,
      username: '什锦4',
      avatar:
        '//sf1-cdn-tos.bdxiguastatic.com/img/user-avatar/e2580b2bb3d06dc4b805488ea57a8e0a~80x80.image',
      createTime: '2020-7-12',
      commentContent: '作者我给你99怕你多了一分，你我怕你骄傲。',
      thumbsUpCount: 5,
      replayCount: 2,
      isAgree: false,
    },
  ];
</script>

<style lang="scss " scoped>
  .video_discuss {
    width: 100%;
    box-sizing: border-box;

    .video_discuss_total {
      font-weight: 700;
      font-size: 18px;
    }

    .comment-component-tabs__container {
      border-bottom: 1px solid rgba(12, 13, 15, 0.06);;
      display: flex;
      padding-bottom: 8px;
      position: relative;

      .comment-component-tab {
        display: inline-block;
        position: relative;
        margin-right: 20px; /* 间距 */
      }

      .comment-component-tabs__tabItem {
        background: transparent;
        border: none;
        padding: 10px 20px;
        font-size: 16px;
        cursor: pointer;
        position: relative;
      }

      .comment-component-tabs__tabItem.active {
        font-weight: bold;
      }

      .comment-component-tabs__ink {
        content: '';
        position: absolute;
        left: 0;
        bottom: 0;
        width: 0;
        height: 2px;
        background: #a9acb1;
        transition: width 0.3s ease, left 0.3s ease;
      }

      .comment-component-tabs__tabItem.active + .comment-component-tabs__ink {
        width: 100%;
      }

      .comment-component-tabs__tabItem:nth-child(1).active + .comment-component-tabs__ink {
        left: 0;
      }

      .comment-component-tabs__tabItem:nth-child(2).active + .comment-component-tabs__ink {
        left: 100%;
      }
    }

    .commentWriter {
      margin: 10px 0;
      display: flex;

      .commentWriter_avatar {
        padding-right: 20px;
      }

      .commentWriter_container {
        display: flex;
        flex: 1;
        position: relative;

        .commentWriter_container_input {
          flex: 1;
          padding: 0 40px 0 20px;
        }

        .commentWriter_container_btn {
          width: 90px;
          margin-left: 20px;
          background-color: #8ec2c2;
          border: none;
          border-radius: 5px;
          cursor: pointer;
        }

        .commentWriter_container_btn:hover {
          background-color: #13C2C2;
        }

        .commentWriter_emoji {
          position: absolute;
          width: 30px;
          top: 6px;
          right: 110px;
        }
      }
    }

    .comment_list {
      padding: 10px 0;
    }
  }
</style>
